package java14;

import lombok.Data;

public class NullPointerSample {

    public static void main(String[] args) {
        // =================================
        // 空指针异常精准提示
        // =================================
        User user = new User();
        user.mail = "13800138000@mail.com";
        // NullPointerException: Cannot invoke "String.equals(Object)" because "user.name" is null
        if (user.name.equals("admin")) {
            System.out.println(user.getMail());
        }
    }

    @Data
    static class User {
        private String name;
        private String mail;
    }

}